<%@ page language="java" contentType="text/html; charset=UTF-8"  
    pageEncoding="UTF-8"%>  
<%  
request.setCharacterEncoding("utf-8");  
String foodid = request.getParameter("foodid"); // 可能对于新增操作来说不需要  
String foodname = request.getParameter("foodname");  
String fooddescribe = request.getParameter("fooddescribe");  
String foodprice = request.getParameter("foodprice");  
String deskid = request.getParameter("deskid");  
String btn = request.getParameter("btn");  
  
// 构造SQL  
String sql = "";  
// 新增  
if ("新增".equals(btn)) {  
    sql = "INSERT INTO shoppingcart(foodname, fooddescribe, foodprice, deskid) VALUES('" +   foodname + "', '" + fooddescribe + "', '" + foodprice + "', '" + deskid + "')";  
}  
// 修改  
 if ("修改".equals(btn)) {  
    // 注意：这里应该有一个WHERE子句来指定要更新的记录  
    // 假设您有一个foodid来唯一标识记录  
    sql = "UPDATE shoppingcart SET foodname='" + foodname + "', fooddescribe='" + fooddescribe +   "', foodprice='" + foodprice + "', deskid='" + deskid + "' WHERE foodid=" + foodid;  
}  
// 删除（虽然您的原始代码中没有这个选项，但我也包括它）  
else if ("del".equals(btn)) {  
    sql = "DELETE FROM shoppingcart WHERE foodid=" + foodid+"";  
}  
  
// 执行SQL（注意：这里应该使用PreparedStatement和连接池）  
int ret = com.myweb.DBTools.update(sql);  
System.out.println("ret=" + ret);  
  
// 重定向到foodlist.jsp  
response.sendRedirect("foodlist.jsp");  
%>